<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        table {
            margin: 100px auto;
        }

        thead {
            background-color: skyblue;
        }

        tbody td {
            border-bottom: 1px solid #ccc;
        }

        .bs {
            background-color: red;
        }
    </style>
</head>

<body>
    <table>
        <thead>
            <tr>
                <th>代码</th>
                <th>代码</th>
                <th>代码</th>
                <th>代码</th>
                <th>代码</th>
                <th>代码</th>
            </tr>

        </thead>
        <tbody>
            <tr>
                <td>003526</td>
                <td>003526</td>
                <td>003526</td>
                <td>003526</td>
                <td>003526</td>
                <td>003526</td>
            </tr>
            <tr>
                <td>003526</td>
                <td>003526</td>
                <td>003526</td>
                <td>003526</td>
                <td>003526</td>
                <td>003526</td>
            </tr>
            <tr>
                <td>003526</td>
                <td>003526</td>
                <td>003526</td>
                <td>003526</td>
                <td>003526</td>
                <td>003526</td>
            </tr>
            <tr>
                <td>003526</td>
                <td>003526</td>
                <td>003526</td>
                <td>003526</td>
                <td>003526</td>
                <td>003526</td>
            </tr>
            <tr>
                <td>003526</td>
                <td>003526</td>
                <td>003526</td>
                <td>003526</td>
                <td>003526</td>
                <td>003526</td>
            </tr>
            <tr>
                <td>003526</td>
                <td>003526</td>
                <td>003526</td>
                <td>003526</td>
                <td>003526</td>
                <td>003526</td>
            </tr>
        </tbody>
    </table>
    <script>
        //  鼠标经过表格主体的每一行就变色
        var tby = document.querySelector('tbody').querySelectorAll('tr')
        // 2.给每一行都绑定鼠标经过事件
        for (var i = 0; i < tby.length; i++) {
            tby[i].onmouseover = function () {
                this.className = 'tby bs'
        }
        //    再给每一行绑定一个光标离开事件
        tby[i].onmouseout = function() {
            this.className = 'tby'
        }
          
        }

    </script>
</body>

</html>